/**
 * 登录、注册、登出等认证相关接口
 */
import request from '@/config/request'
import type { LoginForm } from '@/types/auth'
import { PlatformRegisterReqVO } from '@/types/auth'

/**
 * 登录
 */
export const login = (data: LoginForm) => {
  return request.post({ url: '/system/auth/login', data })
}

/**
 * 退出登录
 */
export const logout = () => {
  return request.post({ url: '/system/auth/logout' })
}

/**
 * 获取用户登录信息
 */
export const userLoginProfile = () => {
  return request.get({ url: '/system/auth/user/profile' })
}

/**
 * 通过用户帐号查询用户邮箱
 */
export const getUserEmail = (username: string) => {
  return request.get({ url: '/system/auth/user/getUserEmail', params: { username } })
}

/**
 * 注册帐号
 */
export const registerUser = (data: PlatformRegisterReqVO) => {
  return request.post({ url: '/system/auth/register', data })
}
